package it.bit.jlightqueryer.conn;

import java.io.File;
import java.io.IOException;

import it.bit.util.PropertiesFile;

/**
 * Class to handle recent Connections directly in a property file
 * @author PerezDeQueya80
 */
public class Recents extends PropertiesFile {

	private static final long serialVersionUID = -8838537425868207082L;
	private static String PREFIX = "recents.";

	public Recents() throws IOException {
		super(new File("recents.properties"));
	}

	public int getCount() {
		return Integer.parseInt(getProperty("count", "0"));
	}

	public void setCount(int c) {
		setProperty("count", ""+c);
	}

	public String getProperty(String key) {
		return super.getProperty(PREFIX+key);
	}

	public String getProperty(int idx, String key) {
		return getProperty(idx+"."+key);
	}

	public synchronized Object setProperty(String key, String value) {
		return super.setProperty(PREFIX+key, value);
	}

	public synchronized Object setProperty(int idx, String key, String value) {
		return setProperty(idx+"."+key, value);
	}

}
